import { getWifiList } from '@/api/innerProject/5gNetManage'

const state = {
  wifiList: [],
  total: '',
  index: ''
}

const mutations = {
  // 设置wifi详细信息
  set_wifiList (state, list) {
    state.wifiList = list
  },
  // 总数
  list_count (state, total) {
    state.total = total
  }
}

const actions = {
  // 获取wifi内容列表
  getWifiList ({ commit }) {
    const projectId = localStorage.getItem('projectId')
    return new Promise((resolve, reject) => {
      getWifiList(projectId)
        .then(res => {
          commit('set_wifiList', res.data.data)
          commit('list_count', res.data.data.length)
          resolve(res)
        })
        .catch(err => {
          reject(err)
        })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
